import {request} from "./request";

//用户添加商品至购物车或增加商品数量
export function addGoods(paramsObj){
    return request({
        url: '/car/addGoods',
        method: 'put',
        data: {
            userid: paramsObj.userid,
            gid: paramsObj.gid,
            gname: paramsObj.gname,
            gimg: paramsObj.gimg,
            gcount: paramsObj.gcount,
            gprice: paramsObj.gprice,
            gcolor: paramsObj.gcolor
        }
    })
}

//如果该用户未拥有购物车列表则直接创建
export function getGoods(userid){
    return request({
        url: '/car/getGoods',
        params: {
            userid
        }
    })
}

//直接删除整类商品
export function delGoods(userid,gid,gcolor){
    return request({
        url: '/car/delGoods',
        method: 'put',
        data: {
            userid,
            gid,
            gcolor
        }
    })
}

//清空用户购物车
export function clearCar(userid){
    return request({
        url: '/car/clearGoods',
        params:{
            userid
        }
    })
}

//更改购物车商品数量
export function changeNum(userid,gid,gcolor,type){
    return request({
        url: '/car/changeCount',
        method: 'put',
        data: {
            userid,
            gid,
            gcolor,
            type
        }
    })
}